<!DOCTYPE html>
<!-- saved from url=(0040)https://wechat.34580.com/vip/birth_gifts -->
<html style="font-size: 20px;"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

	<meta name="author" content="www.34580.com">
	<meta name="keywords" content="">
	<meta name="description" content="">
	<meta name="format-detection" content="telephone=no">
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height">
	<title>菜仙姑</title>
	<link rel="shortcut icon" href="http://sz.34580.com/favicon.ico">
	<link href="css/memberv1.06.min.css" rel="stylesheet">
	<script src="css/jquery-2.2.1.min.js"></script>
</head>
<body>

<link href="css/swiper.min.css" rel="stylesheet">
<style>
	.head img {
		background: #fff;
	}

	.member-details-footer.disabled {
		background: #ccc !important;
	}
	.coupon-red .pro-type{
		float: left;
		font-size: 3.35rem;
	}
	.coupon-red .pro-price{
		font-size: 1.2rem !important;
		margin-top: .7rem;
	}
</style>

<div class="nctouch-main-layout">
	<div class="nctouch-member">
		<div class="member-details">
			<div class="member-details-header">
				<div class="swiper-container swiper-container-horizontal">
					<div class="swiper-wrapper" style="transform: translate3d(223.333px, 0px, 0px); transition-duration: 0ms;">
						<div class="swiper-slide swiper-slide-active" style="width: 193.333px; padding-right: 30px; margin-right: 30px;">
							<div class="painting first level1">
								<a href="javascript:;" class="level level1 head"><img src="css/img/cell_user.png"></a>
								<i class="name">注册会员</i>
							</div>
						</div>
						<div class="swiper-slide swiper-slide-next" style="width: 193.333px; padding-right: 30px; margin-right: 30px;">
							<div class="painting  ">
								<a href="javascript:;" class="level level2 "></a>
								<i class="name">初入食境</i>
							</div>
						</div>
						<div class="swiper-slide" style="width: 193.333px; padding-right: 30px; margin-right: 30px;">
							<div class="painting  ">
								<a href="javascript:;" class="level level3 "></a>
								<i class="name">居家小厨</i>
							</div>
						</div>
						<div class="swiper-slide" style="width: 193.333px; padding-right: 30px; margin-right: 30px;">
							<div class="painting  ">
								<a href="javascript:;" class="level level4 "></a>
								<i class="name">美味达人</i>
							</div>
						</div>
						<div class="swiper-slide" style="width: 193.333px; padding-right: 30px; margin-right: 30px;">
							<div class="painting  ">
								<a href="javascript:;" class="level level5 "></a>
								<i class="name">烹饪大师</i>
							</div>
						</div>
						<div class="swiper-slide" style="width: 193.333px; padding-right: 30px; margin-right: 30px;">
							<div class="painting  ">
								<a href="javascript:;" class="level level6 "></a>
								<i class="name">宫廷御厨</i>
							</div>
						</div>
						<div class="swiper-slide" style="width: 193.333px; padding-right: 30px; margin-right: 30px;">
							<div class="painting  ">
								<a href="javascript:;" class="level level7 "></a>
								<i class="name">金牌厨神</i>
							</div>
						</div>
						<span class="linear"></span>
						<span class="linear_mask" style="width: 111.5px;"></span>
					</div>
				</div>
			</div>
			<div class="member-details-center">
				<div class="gift-box">
					<h1 id="gift_info">此等级不享受生日礼包</h1>

					<p>
						生日礼包可在会员中心-“生日礼包”中领取。已完善个人生日信息的，居家小厨及以上等级会员，在生日时均可领取生日礼包一份。每个食行会员在一个自然年内只能领取一次生日礼包。生日礼包领取有效期为30天，生日当天开始发放。若有效期内未领取，不再补发生日礼包哦~<br>
						完善生日信息请至“我的”-“设置”-“个人设置”。</p>
				</div>
			</div>
			<div class="member-details-footer disabled">不可领</div>
		</div>
	</div>
</div>
<div class="modal-backdrop"></div>
<div class="gift-modal in">
	<div class="gift-modal-header">
		<button type="button" class="close"></button>
		<h4 class="modal-title">领取成功！</h4>
	</div>
	<div class="gift-modal-body">
		<ul class="coupon-list"></ul>
	</div>
	<div class="gift-modal-footer">
		<a href="https://wechat.34580.com/my/red" class="btn_check disable">立即查看</a>
	</div>
</div>
<script src="css/swiper.jquery.min.js"></script>
<script>
	$(function(){
		var is_app = 0;
		var gifts = {
		1:{"Info":"\u6b64\u7b49\u7ea7\u4e0d\u4eab\u53d7\u751f\u65e5\u793c\u5305","Amount":0,"GiftStuts":0,"LevelGiftPackageId":0}		};
		//var curr_gift = {"Info":"\u6b64\u7b49\u7ea7\u4e0d\u4eab\u53d7\u751f\u65e5\u793c\u5305","Amount":0,"GiftStuts":0,"LevelGiftPackageId":0};
		var level = 1;
		var time = 1000;//滑动到等级的时间
		$('#level').addClass('v' + level);
		//初始化等级
		var swiper = new Swiper('.swiper-container', {
			slidesPerView      : 3,
			centeredSlides     : true,
			paginationClickable: true,
			spaceBetween       : 30,
			slideToClickedSlide: true,
			onSlideChangeEnd   : function(swiper){
				//等级切换事件
				var index = swiper.activeIndex + 1;
				// console.log(index);
				level = index;
				// check_receivable(index);
				// $('.level .v' + index).show().siblings().hide(); //升级礼包图片切换
			}
		});
		$('.swiper-wrapper .swiper-slide').each(function(){
			var right = $(this).css('marginRight');
			$(this).css({"margin-right": 0, "padding-right": right});
		});
		//根据等级计算进度条
		var slide = $('.swiper-slide').width();
		var length = level == 7?((slide + 30) * level) - slide - 30:((slide + 30) * level) - slide / 2 - 15;
		$('.linear_mask').width(length);
		//滚动到当前等级
		swiper.slideTo((level - 1), time, false);

		function printf(){
			var num = arguments.length;
			var oStr = arguments[0];
			for(var i = 1; i<num; i++){
				var pattern = "\\{" + (i - 1) + "\\}";
				var re = new RegExp(pattern, "g");
				oStr = oStr.replace(re, arguments[i]);
			}
			return oStr;
		}

		/**
		 * 检查该等级是否可领取生日礼包
		 * @param level
		 */
		// function check_receivable(level){
		// 	// console.log(level);
		// 	if(typeof gifts[level] !== 'undefined'){
		// 		gen_gift_status(gifts[level]);
		// 		return;
		// 	}
		// 	var data = {level: level, gift_type: 0};
		// 	$.post('https://wechat.34580.com/vip/check_gift_status', data, function(res){
		// 		if(res.success == 1){
		// 			gifts[level] = res.data;
		// 			gen_gift_status(res.data);
		// 		}else{
		// 			alert(res.msg);
		// 		}
		// 	})
		// }

		function gen_gift_status(status){
			// console.log(status);
			$("#gift_info").html(status['Info']);
			var e = $('#birthday_gift');

			e.find('div').get(0).className = status['GiftStuts'] == 0?'disabled':(status['GiftStuts'] == 1?'unclaimed':'receive');
			e.find('h3').html('价值' + status['Amount'] + '元生日礼包');
			var btn = $(".member-details-footer");
			if (status['GiftStuts'] == 1){
				btn.removeClass('disabled').html('立即领取');
			}else if(status['Info'] == '您还没设置生日信息'){
				btn.removeClass('disabled').html('完善信息');
			}else{
				btn.addClass('disabled').html(status['GiftStuts'] == 0?'不可领':'已领取');
			}
		}

		function gen_coupons(coupons){
			var temp = '<li class="coupon-red">' +
				'<div class="coupon-a">' +
				'<div class="coupon-content">' +
				'<p class="pro-type">{0}</p>' +
				'<p class="pro-price">{1}</p>' +
				'<p class="pro-info">{2}</p>' +
				'</div>' +
				'<div class="coupon-footer">{3}—{4}<em>x{5}</em></div>' +
				'</div>' +
				'</li>';
			var out = '';
			var coupon_num = 0;
			for(var i = 0; i<coupons.length; i++){
				var coupon = coupons[i];
				out += printf(temp, '￥' + coupon['CanUseMoney'], coupon['Name'], coupon['Description'], coupon['StartTime'], coupon['EndTime'], coupon['Count']);
				coupon_num += coupon['Count'];
			}
			$('.member-details-footer').addClass('disabled').html('已领取');
			$(".modal-title").html('领取成功！共' + coupon_num + '张');
			$('.coupon-list').html(out);
			out = null;
			// $("#birthday_gift div").removeClass('unclaimed').addClass('receive');
			gen_gift_status(gifts[level]);

			$('.gift-modal').addClass('bounceInDown');
			$('.modal-backdrop,.gift-modal').show();
			$("body").css({overflow: "hidden"});
			setTimeout(function(){
				$('.gift-modal').removeClass('bounceInDown');
			}, 1000);
		}

		/**
		 * 领取礼包
		 */
		function receive_coupon(){
			var curr_gift = gifts[level];
			if(curr_gift['GiftStuts'] != 1){
				if (curr_gift['Info']=='您还没设置生日信息'){
					window.location.href='https://wechat.34580.com/my/changeAccountSetting';
					return;
				}else{
					return false
				}
			}
			$.post('https://wechat.34580.com/vip/receive_coupon', {package_id: curr_gift['LevelGiftPackageId']},
				function(res){
					if(res.success == 1){
						curr_gift['GiftStuts'] = 2;
						curr_gift['Info'] = '您已领取该等级生日礼包';
						gen_coupons(res.data);
					}else{
						alert(res.msg);
					}
				}
			);
		}

		//弹出领取奖品层
		$('.member-details-footer').click(receive_coupon);

		//关闭领取奖品层
		$('.gift-modal-header .close,.modal-backdrop').click(function(){
			$('.gift-modal').addClass('bounceOutUp');
			$('body').css({"overflow-y": "auto"});
			setTimeout(function(){
				$('.modal-backdrop,.gift-modal').hide();
				$('.gift-modal').removeClass('bounceOutUp');
			}, 1000)
		});

	})
</script>
<script>
	$(function () {
		oInit();
		$(window).resize(function () {
			oInit();
		});
		//微信禁止放大缩小
		if (typeof WeixinJSBridge == "object" && typeof WeixinJSBridge.invoke == "function") {
			handleFontSize();
		} else {
			if (document.addEventListener) {
				document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
			} else if (document.attachEvent) {
				document.attachEvent("WeixinJSBridgeReady", handleFontSize);
				document.attachEvent("onWeixinJSBridgeReady", handleFontSize);
			}
		}

		function handleFontSize() {
			// 设置网页字体为默认大小
			WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize': 0 });
			// 重写设置网页字体大小的事件
			WeixinJSBridge.on('menu:setfont', function () {
				WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize': 0 });
			});
		}
	});
	function oInit() {
		//控制网页字体大小
		var _width = $(document).width() > 640 ? 640 : $(document).width();
		var size = (_width / 320) * 10;
		sizes = size;
		$("html").css("font-size", size);
		$('.nctouch-main-layout').show();
	}
</script>


</body></html>